import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  // {
  //   title: '税源地',
  //   align: "center",
  //   dataIndex: 'companyId_dictText'
  // },
  // {
  //   title: '商户ID',
  //   align: "center",
  //   dataIndex: 'businessId_dictText'
  // },
  {
    title: '服务类型',
    align: "center",
    dataIndex: 'signingService_dictText'
  },
  {
    title: '任务描述',
    align: "center",
    dataIndex: 'introduce',
    ellipsis: true,
    customRender:({text}) =>{
      return !text ? "-" : text;
    },
  },
  {
    title: '合作邀请码',
    align: "center",
    dataIndex: 'invitationCodeWx',
    helpMessage: ['点击可预览多张图片'],
    width: 140,
    slots: { customRender: 'imgSlot' },
  },
  // {
  //   title: '支付宝邀请码',
  //   align: "center",
  //   dataIndex: 'invitationCodeZfb',
  //   helpMessage: ['点击可预览多张图片'],
  //   width: 140,
  //   slots: { customRender: 'imgSlot' },
  // },
  {
    title: '状态',
    align: "center",
    dataIndex: 'status',
    filters: [
      { text: '开启', value: '1' },
      { text: '关闭', value: '0' },
    ],
    filterMultiple: false,
    slots: { customRender: 'isOpenSlot' },
  },
  // {
  //   title: '审核状态',
  //   align: "center",
  //   dataIndex: 'checkStatus',
  //   filters: [
  //     { text: '审核中', value: '0' },
  //     { text: '审核通过', value: '1' },
  //     { text: '审核拒绝', value: '2' },
  //   ],
  //   filterMultiple: false,
  //   slots: { customRender: 'checkStatusSlot' },
  // },
  {
    title: '创建时间',
    align: "center",
    sorter: true,
    dataIndex: 'createTime',
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "创建时间",
    field: "createTime",
    component: 'RangePicker',
    componentProps: {
      showTime: true,
    },
    colProps: {span: 6},
  },
  {
    label: "签约服务类型",
    field: 'signingService',
    component: 'JSelectMultiple',
    componentProps: {
      dictCode: "caishui_signing_service,name,id"
    },
    colProps: {span: 6},
  },
  {
    label: "状态：0-关闭，1-开启",
    field: 'status',
    component: 'JSwitch',
    componentProps:{
    },
    colProps: {span: 6},
  },
  {
    label: "审核状态：0-审核中，1-审核通过，2-审核拒绝",
    field: 'checkStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "check_status"
    },
    colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '税源地ID',
    field: 'companyId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "caishui_service_company,name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入税源地ID!'},
             ];
    },
  },
  {
    label: '商户ID',
    field: 'businessId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "caishui_business,name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入商户ID!'},
             ];
    },
  },
  {
    label: '签约服务类型',
    field: 'signingService',
    component: 'JSelectMultiple',
    componentProps:{
      dictCode: "caishui_signing_service,name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入签约服务类型!'},
             ];
    },
  },
  {
    label: '任务标题',
    field: 'title',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入任务标题!'},
             ];
    },
  },
  {
    label: '任务介绍',
    field: 'introduce',
    component: 'Input',
  },
  {
    label: '合作邀请码（微信小程序码）',
    field: 'invitationCodeWx',
    component: 'JImageUpload',
    componentProps:{
      fileMax: 1
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入合作邀请码（微信小程序码）!'},
             ];
    },
  },
  {
    label: '状态：0-关闭，1-开启',
    field: 'status',
    component: 'JSwitch',
    componentProps:{
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入状态：0-关闭，1-开启!'},
             ];
    },
  },
  {
    label: '审核状态：0-审核中，1-审核通过，2-审核拒绝',
    field: 'checkStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "check_status"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入审核状态：0-审核中，1-审核通过，2-审核拒绝!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
